;
(function() {
	var role = require("./role");
	var BusCon = require("../../core/bus/_con");
	var UserCon = require("../../core/user/_con");
	var GoodsCon = require("../../core/goods/_con");
	var AchCon = require("../../core/ach/_con");
	var db = require("../../core/db/index");
	var config = require("../../core/_include/config");
	var ResponObj = require("../_include/responObj");

	module.exports = {
		prefix: "/bus/coupon",
		get: {
			"/list": function() {
				var bus = role.getBus(this);
				var query = this.request.query;
				var result = bus.getCouponList(query.num, query.page);
				this.body = ResponObj("json", result);
			}
		},
		post: {
			"/new": function() {
				var bus = role.getBus(this);
				var coupon_info = this.request.body;
				bus.add打折Coupon(coupon_info);
				return module.exports.get["/list"].apply(this, arguments);
			}
		},
		"delete": {
			"/remove/:coupon_id": function() {
				var bus = role.getBus(this);
				var coupon_id = this.params.coupon_id;
				if (!coupon_id) {
					throwCusError("参数错误");
				}
				bus.removeCoupon(coupon_id);
				return module.exports.get["/list"].apply(this, arguments);
			}
		}
	}
}());